package com.ads.tpgrupo4.server.service.maestroDeRodamientos;

import java.util.List;

import com.ads.tpgrupo4.domain.cpr.core.Rodamiento;
import com.ads.tpgrupo4.server.config.Config;
import com.ads.tpgrupo4.server.xml.FIlePathXmlSource;
import com.ads.tpgrupo4.server.xml.XmlSource;
import com.ads.tpgrupo4.server.xml.mappers.MaestroDeRodamientosXmlMapper;

public class MaestroDeRodamientosRetrieverRemoteServiceImpl implements MaestroDeRodamientosRetrieverRemoteService {
	
	private static MaestroDeRodamientosRetrieverRemoteServiceImpl instance;

	private Config config = Config.getInstance();
	private MaestroDeRodamientosXmlMapper maestroDeRodamientosXmlMapper = MaestroDeRodamientosXmlMapper.getInstance();
	
	public static MaestroDeRodamientosRetrieverRemoteServiceImpl getInstance() {

		if (instance == null) {
			instance = new MaestroDeRodamientosRetrieverRemoteServiceImpl();
		}
		
		return instance;
	}
	
	private MaestroDeRodamientosRetrieverRemoteServiceImpl() {
	}
	
	@Override
	public List<Rodamiento> getRodamientos() {
		
		final XmlSource maestroDeRodamientosXMLSource = new FIlePathXmlSource(config.getMaestroDeRodamientosFilePath());
		final List<Rodamiento> rodamientos = maestroDeRodamientosXmlMapper.map(maestroDeRodamientosXMLSource);
		
		return rodamientos;
	}

}
